package com.bbm.bbmanage.controller;



import com.bbm.bbmanage.entity.HouseProperty;
import com.bbm.bbmanage.entity.dto.HousePropertyDTO;
import com.bbm.bbmanage.entity.vo.ResponseResult;
import com.bbm.bbmanage.service.HousePropertyService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * (HouseProperty)表控制层
 *
 * @author lionkliu
 * @since 2024-03-23 18:49:50
 */
@RestController
@RequestMapping("houseProperty")
public class HousePropertyController {

    @Resource
    private HousePropertyService housePropertyService;

    @GetMapping("/page")
    public ResponseResult selectPage(@RequestParam("pageNum") Integer pageNum,
                                     @RequestParam("pageSize") Integer pageSize) {
        return housePropertyService.selectPage(pageNum,pageSize);
    }

    @GetMapping("{id}")
    public ResponseResult getPropertiesByHouseId(@PathVariable Long id) {
        return housePropertyService.getPropertiesByHouseId(id);
    }

    @GetMapping("/label/{houseId}")
    public ResponseResult getPropertiesLabelValueByHouseId(@PathVariable Long houseId) {
        return housePropertyService.getPropertiesLabelValueByHouseId(houseId);
    }

    @PostMapping
    public ResponseResult insert(@RequestBody HousePropertyDTO houseProperty) {
        return housePropertyService.insert(houseProperty);
    }

    @PutMapping
    public ResponseResult update(@RequestBody HouseProperty houseProperty) {
        return housePropertyService.updateOne(houseProperty);
    }

    @DeleteMapping("/{id}")
    public ResponseResult delete(@PathVariable Integer id) {
        return housePropertyService.deleteById(id);
    }

}
